import pyAxios from "./http";

// 获取该老师的班级信息
async function getClassList(teacherId) {
    try {
        const response = await pyAxios({
            method: 'get',
            url: '/teacher/getClassList',
            params:{
                teacherId
            }
        })
        return response;
    } catch (error) {
        console.log(error);

    }
}

// 创建班级
async function addClass(className) {
    try {
        const response = await pyAxios({
            method: 'post',
            url: '/teacher/addClass',
            data: className,
        })
        return response;
    } catch (error) {
        console.log(error);

    }
}

// 删除班级
async function deleteClass(classId,teacherId) {
    try {
        const response = await pyAxios({
            method: 'delete',
            url: '/teacher/deleteClass',
            params:{
                classId,
                teacherId
            }
        })
        return response;
    } catch (error) {
        console.log(error);

    }
}
// 删除学生
async function deleteStudent(classId,studentId) {
    try {
        const response = await pyAxios({
            method: 'delete',
            url: '/teacher/deleteStudent',
            params:{
                classId,
                studentId
            }
        })
        return response;
    } catch (error) {
        console.log(error);

    }
}
// 老师发送通知
async function sendInform(InformData) {
    try {
        const response = await pyAxios({
            method: 'post',
            url: '/teacher/sendInform',
            data: InformData
        })
        return response;
    } catch (error) {
        console.log(error);

    }
}

// 获取该老师的学生列表
async function getStudentList(teacherId) {
    try {
        const response = await pyAxios({
            method: 'get',
            url: '/teacher/getStudentList',
            params:{
                teacherId
            }
        })
        return response;
    } catch (error) {
        console.log(error);

    }
}

// 获取该老师查询的学生
async function queryStudent(teacherId,query) {
    try {
        const response = await pyAxios({
            method: 'get',
            url: '/teacher/queryStudent',
            params:{
                teacherId,
                query
            }
        })
        return response;
    } catch (error) {
        console.log(error);

    }
}
//获取老师的文件列表数据
async function getMaterialList(teacherId) {
    try {
        const response = await pyAxios({
            method: 'get',
            url: '/teacher/getMaterialList',
            params:{
                teacherId
            }
        })
        return response;
    } catch (error) {
        console.log(error);
    }
}

//老师删除上传的文件列表信息
async function deleteMaterial(materialId) {
    try {
        const response = await pyAxios({
            method: 'delete',
            url: '/teacher/deleteMaterial',
            params:{
                materialId
            }
        })
        return response;
    } catch (error) {
        console.log(error);
    }
}

// 老师添加题库
async function addTopics(formData) {
    try {
        const response = await pyAxios({
            method: 'post',
            url: '/teacher/addTopics',
            data: formData
        })
        return response;
    } catch (error) {
        console.log(error);

    }
}

//获取老师自己的题库
async function getTopicList(teacherId) {
    try {
        const response = await pyAxios({
            method: 'get',
            url: '/teacher/getTopicList',
            params:{
                teacherId
            }
        })
        return response;
    } catch (error) {
        console.log(error);
    }
}

// 从题库中删除题目
async function deleteTopic(topicId) {
    try {
        const response = await pyAxios({
            method: 'delete',
            url: '/teacher/deleteTopic',
            params:{
                topicId
            }
        })
        return response;
    } catch (error) {
        console.log(error);

    }
}

// 老师添加试卷
async function createExam(formData) {
    try {
        const response = await pyAxios({
            method: 'post',
            url: '/teacher/createExam',
            data: formData
        })
        return response;
    } catch (error) {
        console.log(error);

    }
}

//获取老师的考试列表数据
async function getExamList(teacherId) {
    try {
        const response = await pyAxios({
            method: 'get',
            url: '/teacher/getExamList',
            params:{
                teacherId
            }
        })
        return response;
    } catch (error) {
        console.log(error);
    }
}

// 从题库中删除题目
async function deleteExam(examId) {
    try {
        const response = await pyAxios({
            method: 'delete',
            url: '/teacher/deleteExam',
            params:{
                examId
            }
        })
        return response;
    } catch (error) {
        console.log(error);

    }
}

//获取老师的考试列表数据
async function getCorrectTestPaper(teacherId) {
    try {
        const response = await pyAxios({
            method: 'get',
            url: '/teacher/getCorrectTestPaper',
            params:{
                teacherId
            }
        })
        return response;
    } catch (error) {
        console.log(error);
    }
}

//获取老师正在改的试卷的数据
async function getAnswerSheet(answerSheetId) {
    try {
        const response = await pyAxios({
            method: 'get',
            url: '/teacher/getAnswerSheet',
            params:{
                answerSheetId
            }
        })
        return response;
    } catch (error) {
        console.log(error);
    }
}


// 老师添加试卷
async function upResult(formData) {
    try {
        const response = await pyAxios({
            method: 'post',
            url: '/teacher/upResult',
            data: formData
        })
        return response;
    } catch (error) {
        console.log(error);

    }
}

//获取老师正在改的试卷的数据
async function getStudentChat(teacherId) {
    try {
        const response = await pyAxios({
            method: 'get',
            url: '/teacher/getStudentChat',
            params:{teacherId}
        })
        return response;
    } catch (error) {
        console.log(error);
    }
}




//获取老师正在改的试卷的数据
async function deleteSession(sessionId) {
    try {
        const response = await pyAxios({
            method: 'delete',
            url: '/teacher/deleteSession',
            params:{sessionId}
        })
        return response;
    } catch (error) {
        console.log(error);
    }
}


//修改课程班级
async function upDateClass(courseId,classIdArray) {
    try {
        const response = await pyAxios({
            method: 'post',
            url: '/teacher/upDateClass',
            data:{
                courseId,
                classIdArray
            }
        })
        return response;
    } catch (error) {
        console.log(error);
    }
}

//删除课程
async function deleteCourse(courseId) {
    try {
        const response = await pyAxios({
            method: 'delete',
            url: '/teacher/deleteCourse',
            params:{courseId}
        })
        return response;
    } catch (error) {
        console.log(error);
    }
}

export default{deleteCourse,upDateClass,deleteSession,getStudentChat,upResult,getAnswerSheet,getCorrectTestPaper,deleteExam,getExamList,createExam,deleteTopic,getTopicList,addTopics,deleteMaterial,getMaterialList,queryStudent,getStudentList,deleteStudent,deleteClass,getClassList,addClass,sendInform}